﻿<!DOCTYPE html>
<html lang="">
<head>
    <meta charset="utf-8" />
    <title>使用DOM判断页面中控件是否嵌套</title>
    <script type="text/javascript">
        function testa(){
            var mydom = document.getElementById("divtest");
            if(mydom.hasChildNodes()){
                alert("有子节点")
            }else{
                alert("没有子节点");
            }
        }
    </script>
</head>
<body>
<form id="form1">
    <input type="button" value="test" onclick="testa()"/>
    <div id="divtest"></div>
</form>
</body>
</html>